﻿package mortal.game.view.common.button
{
    import com.mui.controls.*;
    import com.mui.events.*;
    import flash.events.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;

    public class SortButton extends GSprite
    {
        private var _btn:GLoadedButton;
        private var _mode:int;
        public static const MODE_DESCENDING:int = 1;
        public static const MODE_ASCENDING:int = 2;

        public function SortButton()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._btn = UIFactory.gLoadedButton(ImagesConst.descendingSortBtn_upSkin, 0, 0, 11, 14, this);
            this._btn.configEventListener(MouseEvent.CLICK, this.onMouseClick);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._btn.dispose();
            this._btn = null;
            this._mode = MODE_DESCENDING;
            return;
        }// end function

        private function onMouseClick(event:MouseEvent) : void
        {
            this._btn.styleName = this._btn.styleName == ImagesConst.descendingSortBtn_upSkin ? (ImagesConst.ascendingSortBtn_upSkin) : (ImagesConst.descendingSortBtn_upSkin);
            if (this._btn.styleName == ImagesConst.descendingSortBtn_upSkin)
            {
                this.dispatchEvent(new SortEvent(SortEvent.DESCENDING));
            }
            else
            {
                this.dispatchEvent(new SortEvent(SortEvent.ASCENDING));
            }
            return;
        }// end function

        public function get mode() : int
        {
            return this._mode;
        }// end function

        public function set mode(param1:int) : void
        {
            this._mode = param1;
            return;
        }// end function

    }
}
